package com.example.jdksevendemo.controller;

import com.example.jdksevendemo.service.CopyFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Scanner;

@RestController
@RequestMapping("/FileController")
public class FileController {
    @Autowired
    private CopyFileService copyFileService;


    /**
     * 拷贝文件夹 及其子文件夹和文件  到另一个目录
     * @return
     */
    @GetMapping("/copyDirOrFile")
    public String copyDirOrFile(){
//        Scanner sc = new Scanner(System.in);
//        System.out.println("请输入源目录：");
//        String sourcePath = sc.nextLine();
//        System.out.println("请输入新目录：");
//        String path = sc.nextLine();

        //String sourcePath = "D://aa";
        //String path = "D://bb";

        String sourcePath = "D:\\Data";
        String newPath = "E:\\Data";
        copyFileService.copyDirOrFile(sourcePath,newPath);
        return "success";
    }
}
